package com.bcqn.service;

import com.bcqn.dao.EmployeeMapper;
import com.bcqn.dao.RoleMapper;
import com.bcqn.model.Employee;
import com.bcqn.model.Role;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class AdminService {

    @Resource
    private EmployeeMapper employeeMapper;
    @Resource
    private RoleMapper roleMapper;

    public int insertUser(Employee user) {
        return employeeMapper.insertSelective(user);
    }

    public int updateUser(Employee user) {
        return employeeMapper.updateByPrimaryKeySelective(user);
    }

    public Employee getUserByEmployeeId(Long ee_id) {
        return employeeMapper.selectByPrimaryKey(ee_id);
    }

    public Employee getUserByPhone(String phone) {
        return employeeMapper.selectUserByPhone(phone);
    }

    public Employee getUserByEmail(String email) {
        return employeeMapper.selectUserByEmail(email);
    }

    public Employee getUserByUserName(String userName) {
        return employeeMapper.selectUserByUserName(userName);
    }

    public Employee getUserInfoByEmployeeId(Long ee_id) {
        return employeeMapper.selectUserInfoByEmployeeId(ee_id);
    }

    public int insertRole(Role role) {
        return roleMapper.insertSelective(role);
    }
}
